LINQ to XML - Miscellaneous Samples


LINQ, LINQ to XML, .NET Framework 4.0
LINQ, LINQ to XML, XML, Console Window, XML Documentation
Desktop, Data
en-US
6/28/2011

Introduction

These samples demonstrate various ways of working with XML data.

Building the Sample

Are there special requirements or instructions for building the sample?

Description

These samples include:

Screenshot

Sample Code

C#
Edit|Remove
            [Category("Misc")] 
            [Description("Check if an element has element children")] 
            public void XLinq93() 
            { 
                XDocument doc = XDocument.Load("nw_customers.xml"); 
                XElement e = doc.Element("Root") 
                                .Element("Customers"); 
                Console.WriteLine("Customers has elements? {0}", e.HasElements); 
 
            }

Source Code Files

More Information

For more information on LINQ to XML: http://msdn.microsoft.com/en-us/library/bb387098.aspx